<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ice="http://www.icesoft.com/icefaces/component"
    template="/layout/template.xhtml">

    <ui:define name="head">
        <link href="../stylesheet/useradmin.css" rel="stylesheet" type="text/css"/>

        <script type="text/javascript">
function confirmDelete()
{
    return confirm("Are you sure you wish to delete this user? This action cannot be undone.");
}
        </script>
    </ui:define>

    <ui:define name="body">

        <h1>User Manager</h1>

        <s:button id="newUser" action="#{userAction.createUser}" styleClass="newuser" rendered="#{s:hasPermission('seam.user', 'create')}"/>

        <ice:form id="usersCmdForm">
            <ice:dataTable id="users" var="_user" value="#{users}"
                styleClass="useradmin" headerClass="header" rowClasses="odd,even" columnClasses=",,enabled,action">
                <ice:column id="username">
                    <f:facet name="header">Username</f:facet>
                    #{_user}
                </ice:column>
                <ice:column id="roles">
                    <f:facet name="header">Member of roles</f:facet>
                    #{userSearch.getUserRoles(_user)}
                </ice:column>
                <ice:column id="enabled">
                    <f:facet name="header">Enabled</f:facet>
                    <div class="status-#{identityManager.isUserEnabled(_user)}"/>
                </ice:column>
                <ice:column id="action">
                    <f:facet name="header">Action</f:facet>
                        <s:fragment rendered="#{s:hasPermission('seam.user', 'update')}">
                            <ice:commandLink id="edit" value="Edit" action="#{userAction.editUser(userSearch.selectedUser)}"/><span> | </span>
                        </s:fragment>
                        <ice:commandLink id="delete" value="Delete" action="#{identityManager.deleteUser(userSearch.selectedUser)}"
                            rendered="#{s:hasPermission('seam.user', 'delete')}" onclick="if (!confirmDelete()) return;"/>
                </ice:column>
            </ice:dataTable>
        </ice:form>

    </ui:define>

</ui:composition>
